<div class="layui-form" lay-filter="layuiadmin-form-role" id="form">
	<div class="form-cont">
		<div class="layui-form-item verify">
		  <label class="layui-form-label">配置值</label>
		  <div class="layui-input-block">
			  <input type="text" lay-verify="required" autocomplete="off" verify='requirel5' v-model="detail.disposed_name" placeholder="请输入配置值" class="layui-input">
			  <span class="hint">配置值必填</span>
			</div>
		</div>
		<div class="layui-form-item verify">
		  <label class="layui-form-label">配置类型</label>
		  <div class="layui-input-block">
		      <div class="layui-unselect layui-form-select">
		      	<div class="layui-select-title"><input type="text" verify="require" name='type' :data='detail.type' placeholder="请选择配置类型" class="layui-input layui-unselect" readonly><i
		      		 class="layui-edge"></i></div>
		      	<dl class="layui-anim layui-anim-upbit">
		      		<dd class="layui-select-tips layui-this">请选择</dd>
		      		<dd :data='index+1' v-for="(x,index) in select"  @click="ruleF(index)">{{x}}</dd>
		      	</dl>
		      </div>
			  <span class="hint">配置类型必选</span>
		  </div>
		</div>
	</div>
  
  <div class="form-btn" v-if="type!=3">
      <input type="button" value="保存" class="layui-btn" @click="submit">
  </div>
</div>

<script>
	layui.use(['form'], function(){
	  var $ = layui.$
	  ,form = layui.form;
	  var form=new Vue({
	  		el:'#form',
	  		data:{
	  			detail:{
					status:1
				},
				old_detail:{},
				type:layui.admin.objData.type,
				select:['cpu','内存','显卡','硬盘','显示器','主板']
	  		},
	  		mounted:function() {
				//初始化
	  			if(this.type!=1) this.detail=layui.admin.objData.detail,this.old_detail=JSON.stringify(layui.admin.objData.detail);
				$('input[name="type"]').val(this.select[this.detail.type-1]);
	  		},
	  		methods:{
				ruleF:function(x){//radio选择
					this.detail.type = x;
				},
				submit:function(){
					if(layui.admin.form('#form')){
						this.detail.type=parseInt($($("input[name='type']")[1]).attr('data'));
						
						if(this.type==2){   //编辑
							var data=layui.admin.filter(this.detail,JSON.parse(this.old_detail),'disposed_id');
							if(data){
								layui.admin.formapi('disposed/update',data);
							}
						}else{  //添加
							layui.admin.formapi('disposed/add',this.detail);
						}
					}
				}
	  		}
	  	})
	});
</script>
